﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Xfrog.Windows.DWM;
using System.Drawing;

namespace DWMTest
{
   
    public partial class Form1 : Form
    {
        private DwmForNet dwm;
        public Form1()
        {
            InitializeComponent();
             
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            dwm = new DwmForNet(this);
         //   dwm.EnableComposition(false);
        //   MessageBox.Show( dwm.EnableBlurBehindWindow(this,null,true).ToString());
           dwm.MaximizedChanged += new MaximizedChangedEvent(dwm_MaximizedChanged);
           dwm.ColorChanged += new ColorChangedEvent(dwm_ColorChanged);

           dwm.ExtendFrameIntoClientArea(this, new System.Drawing.Printing.Margins(20,20,20,50));

           IntPtr ptr = Xfrog.Windows.Utils.FindWindowW("Progman", null);

           IntPtr thumb = dwm.RegisterThumbnail(this.Handle,ptr);
          // dwm.UnRegisterThumbnail(thumb);
           DwmThumbnailProperties property = new DwmThumbnailProperties();
           property.dwFlags = DwmTNP.DwmTNPOpacity | DwmTNP.DwmTNPRectDestination | DwmTNP.DwmTNPVisible;
           property.rcDestination.X = 0;
           property.rcDestination.Y = 50;
           property.rcDestination.Width = 100;
           property.rcDestination.Height = 100;
           property.fVisible = true;
           property.opacity = (255 * 70) / 100;
           property.fSourceClientAreaOnly = false;

           dwm.UpdateThumbnailProperties(thumb, property);

           Size size = new Size();
           dwm.QueryThumbnailSourceSize(thumb, ref size);
           MessageBox.Show(size.ToString());

           
         //   property.dwFlags = DwmTNP
        //    dwm.UpdateThumbnailProperties(thumb,
            
        }

        void dwm_ColorChanged(object obj, ColorChangedEventArgs args)
        {
            throw new NotImplementedException();
        }

        void dwm_MaximizedChanged(bool blEnabled)
        {
            throw new NotImplementedException();
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
       //     Rectangle rect = this.Bounds;
       //     rect.Height -= rect.Height / 2;
        //    rect.Offset(-rect.Left, -rect.Top);
    //        dwm.EnableBlurBehindWindow(this, false);
          //  Region r = new Region(rect);
        //    dwm.EnableBlurBehindWindow(this, r, true);
        }
    }
}
